package nlptools.i2b2;

import java.io.File;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MedNameExtractor {
	private static Pattern medPartern = PatternFactory.createPattern(new File("patterns/m.txt"));
	public static Vector<String> getMedicationNames(String sentence)
	{
		Vector<String> medNameVector = new Vector<String>();
		Matcher matcher = medPartern.matcher(sentence);
		while(matcher.find())
		{
			String medName = sentence.substring(matcher.start(), matcher.end());
			String[] tokens = medName.split("\\s+");
			for(String token : tokens)
			{
				token = token.toLowerCase();
				token = token.trim();
				medNameVector.add(token);
			}
		}
		return medNameVector;
	}
}
